/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.dntuan.springmail;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

public class Main {

	public static void main(String[] args) {
		try {
			BeanFactory factory = new XmlBeanFactory(new ClassPathResource("springMail.xml"));
			SimpleMailMessage msg = (SimpleMailMessage) factory.getBean("mailMessage");
			JavaMailSender sender = (JavaMailSender) factory.getBean("mailSender");
			sender.send(msg);
            System.out.println("Sending emails is already done!");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
